package com.antgroup.seckill.business.common.rabbitmq;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * 消息发送者
 *
 * @author wangxy
 * @date 2024/8/3 19:47
 */
@Service
@Slf4j
public class MQSender {


    @Autowired
    private RabbitTemplate rabbitTemplate;

    /*public void send(Object msg) {

        log.info("发消息：" + JSON.toJSONString(msg));
        rabbitTemplate.convertAndSend("queue", msg);
    }

    public void send01(Object msg) {

        log.info("发消息(被QUEUE01)：" + JSON.toJSONString(msg));
        rabbitTemplate.convertAndSend("topicExchange","queue.red.message",msg);
    }

    public void send02(Object msg) {

        log.info("发消息(被两个QUEUE接收)：" + JSON.toJSONString(msg));
        rabbitTemplate.convertAndSend("topicExchange","message.queue.green.abc",msg);
    }*/


    /**
     * 发送秒杀消息
     * @param message
     */
    public void sendSeckillMessage(String message) {
        log.info("发送秒杀消息：" + message);
        rabbitTemplate.convertAndSend("seckillExchange","seckill.message",message);
    }

}
